package com.icedevcloud.upms.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.icedevcloud.upms.entity.SysRolePermission;
import com.icedevcloud.upms.mapper.SysRolePermissionMapper;
import com.icedevcloud.upms.service.ISysRolePermissionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 角色权限关联表 服务实现类
 * </p>
 *
 * @author XiaoBingBy
 * @since 2023-08-13
 */
@Service
public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionMapper, SysRolePermission> implements ISysRolePermissionService {

    @Override
    public List<SysRolePermission> getRolePermissionByRoleId(Long roleId) {
        return this.list(
                Wrappers.<SysRolePermission>lambdaQuery()
                        .eq(SysRolePermission::getRoleId, roleId)
        );
    }

    @Override
    public Boolean removeRolePermissionByPermissionId(Long permissionId) {
        return this.remove(Wrappers.<SysRolePermission>lambdaUpdate().eq(SysRolePermission::getPermissionId, permissionId));
    }

    @Override
    public Boolean removeRolePermissionByRoleId(Long roleId) {
        return this.remove(Wrappers.<SysRolePermission>update().lambda().eq(SysRolePermission::getRoleId, roleId));
    }

}
